/**
 * @description $column.type == 编
 * 富文本编辑
 */

import { Form } from 'antd';
import { useState } from 'react';

import EditorQuill from '../../Editor/editor';
import getRule from '../getRule';

function YyQuill({ column, showLabel }) {

  const [quillValue, setQuillValue] = useState('');

  const handleEditorChange = (value) => {
    setQuillValue(value);
  };

  // [1] 配置校检rules字段。column已经有rules则取，无则重新生成
  let rules = column.rules ? column.rules : getRule(column)

  return (
    <Form.Item
      label={showLabel ? column.comments : null}
      name={column.columnName}
      rules={rules}
      className='quill-item'
    >
      <EditorQuill value={quillValue} onChange={handleEditorChange}></EditorQuill>
    </Form.Item>
  )
}

export default YyQuill